package test

import (
	"errors"
	"fmt"
)

type ColorFul interface {
	getColor() string
	setColor(c string)
}

type Apple struct {
	Color string
}

func (a *Apple) getColor() string {
	return a.Color
}

func (a *Apple) setColor(c string) {
	a.Color = c
}

func PrintColor(c ColorFul) {
	fmt.Println(c.getColor())
	c.setColor("blue")
}

type Person struct {
	name string
	age  int
}

type SuperMan struct {
	Person
	superPower string
}

func ModifyAge(i interface{}, a int) error {
	if value, ok := i.(Person); ok {
		value.age = a
	} else if value, ok := i.(SuperMan); ok {
		value.age = a
	} else {
		return errors.New("not support type")
	}
	return nil
}
